home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Microsoft Programmer's Library
/
Microsoft Programmer's Library (CD-ROM Database)(125-099-008)(Version 1.1a)(CDRM 162100)(1989).iso
/
SAMPCODE
/
OS2SDK11
/
TK4
/
OPENDLG
/
INIT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-20
|
2KB
|
51 lines
/***************************************************************************\
* INIT.C -- Library initialization funcitons
* Created by Microsoft Corporation, 1989
\***************************************************************************/
#include "tool.h"
/****************************************************************************\
* This function initializes the file dialog library (by loading strings).
*
* Note: Initialization will fail if CCHSTRINGSMAX is smaller than the
* space taken up by all strings in the .rc file. Fix by increasing
* CCHSTRINGSMAX in wintool.h and maybe also the initial heap size
* in wintool.def.
*
* Returns:
* TRUE if initialization successful
* FALSE otherwise
\***************************************************************************/
BOOL PASCAL InitLibrary()
{
int i;
int cch;
PSTR pch;
PSTR pmem;
int cchRemaining;
/* allocate memory for strings */
if (!(pch = (pmem = WinAllocMem(vhheap, cchRemaining = CCHSTRINGSMAX))))
return FALSE;
/* load strings from resource file */
for (i = 0; i < CSTRINGS; i++) {
cch = 1 + WinLoadString(HABX, vhModule, i, cchRemaining, (PSZ)pch);
if (cch < 2)
/* loadstring failed */
return FALSE;
vrgsz[i] = pch;
pch += cch;
if ((cchRemaining -= cch) <= 0)
/* ran out of space */
return FALSE;
}
/* reallocate string space to size actually needed */
WinReallocMem(vhheap, pmem, CCHSTRINGSMAX, CCHSTRINGSMAX - cchRemaining);
return TRUE;
}